class TreeNode:
    parent = None
    children: list = []
    val: str = ''
    allVall: str = ''

    def getAllVal(self):
        parent = self.parent
        res = self.val
        while parent is not None:
            res = parent.val + res
            parent = parent.parent
        return res
